﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using OurDailyBread.ViewModel;

namespace OurDailyBread
{
    public sealed partial class MainPage
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void CommentBox_GotFocus(object sender, RoutedEventArgs e)
        {
            if (CommentBox.Text == "Share your thoughts...")
            {
                CommentBox.Text = String.Empty;
            }
        }

        private void CommentBox_LostFocus(object sender, RoutedEventArgs e)
        {
            if (CommentBox.Text == String.Empty)
            {
                CommentBox.Text = "Share your thoughts...";
            }
        }

        private void MyLikesGrid_ItemClick(object sender, ItemClickEventArgs e)
        {
            RoamingLikes clickedLike = (RoamingLikes)e.ClickedItem;
            App app = (App)OurDailyBread.App.Current;
            app.Context.currentDisplayDate = clickedLike.MyLikeBreadDate;
            app.Context.mvw.GetContent(app.Context.currentDisplayDate);
        }

        private void MyLikeGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            bottomAppBar.IsOpen = true;
            RemoveButton.Visibility = Visibility.Visible;

            App app = (App)OurDailyBread.App.Current;
            if (e.AddedItems != null && e.AddedItems.Count != 0)
            {
                app.Context.selectedLike = (RoamingLikes)e.AddedItems[0];
            }
        }
    }
}
